﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/assets/libs/layui/css/layui.css" />
    <link rel="stylesheet" href="/assets/module/admin.css">
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
    </style>
</head>
<body>
    <!-- 主体部分 -->
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 数据表格 -->
                <table id="gridTable" lay-filter="gridTable"></table>
            </div>
        </div>
    </div>

    <!-- 表格操作列 -->
    <script type="text/html" id="toolbar">
        <a id="btnAdd" class="layui-btn layui-btn-sm icon-btn" lay-event="clear"><i class="layui-icon">&#xe639;</i>清空</a>
    </script>

    <!-- js部分 -->
    <script src="/assets/libs/jquery/jquery-3.2.1.min.js"></script>
    <script src="/assets/libs/layui/layui.js"></script>
    <script src="/assets/js/utils.js"></script>
    <script src="/assets/js/main.js"></script>
    <script>

        var JobName = getRequestData("JobName");
        // 全局变量
        var table;

        layui.use(['layer', 'form', 'table', 'util', 'admin', 'setter'], function () {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            table = layui.table;
            var util = layui.util;
            var admin = layui.admin;
            var setter = layui.setter;

            // 表格初始化
            layuiTableSet();

            /* 渲染表格 */
            var insTb = table.render({
                elem: '#gridTable',
                id: "gridTable",
                url: setter.baseServer + '/AutoJobManage/AutoJob/GetPageListJsonForLog',
                page: true,
                toolbar: "#toolbar",
                where: { JobName: JobName },
                cols: [[
                    { type: 'numbers' },
                    { field: 'JobName', title: '任务名称' },
                    {
                        field: 'LogStatus', title: '执行结果', align: 'center', width: 100,
                        templet: function (d) {
                            if (d.LogStatus == "1") {
                                return '<span class="layui-badge layui-badge-blue">成功</span>';
                            } else {
                                return '<span class="layui-badge layui-badge-red">失败</span>';
                            }
                        }
                    },
                    { field: 'Remark', title: '任务信息' },
                    {
                        field: 'BaseCreateTime', title: '创建时间', width: 165, templet: function (d) {
                            return util.toDateString(d.BaseCreateTime, "yyyy-MM-dd HH:mm:ss");
                        }
                    }
                ]]
            });

            /* 表格头工具栏点击事件 */
            table.on('toolbar(gridTable)', function (obj) {
                if (obj.event === 'clear') {
                    admin.showLoading('body', 3, '.8');
                    admin.req('/AutoJobManage/AutoJob/ClearJobLog/JobName', function (res) {
                        admin.removeLoading('body', true, true);
                        if (res.Tag == 1) {
                            layer.msg('操作成功', { icon: 1, time: 1500 });
                            table.reload('gridTable');
                        }
                        else {
                            layer.msg(res.Message, { icon: 2 });
                        }
                    }, 'post');
                }
            });



        });
    </script>
</body>
</html>
